package org.stone.project.ncCheck.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.stone.project.ncCheck.domain.HistoryIp;
import org.stone.project.ncCheck.service.HistoryIpService;
import org.stone.project.ncCheck.mapper.HistoryIpMapper;
import org.springframework.stereotype.Service;
import org.stone.project.ncCheck.utils.IpUtil;

import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

/**
 *
 */
@Slf4j
@Service
public class HistoryIpServiceImpl extends ServiceImpl<HistoryIpMapper, HistoryIp>
    implements HistoryIpService{
    @PostConstruct
    public void logLast(){
        log.info("最近ip对象记录为{}",findLastRecord());
    }

    @Override
    public HistoryIp findLastRecord(){
        LambdaQueryWrapper<HistoryIp> lastQuery = Wrappers.lambdaQuery(HistoryIp.class)
                .last(" limit 1 ");
        return this.baseMapper.selectOne(lastQuery);
    }
}




